/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package co.edu.univalle.logica;

import co.edu.univalle.modelo.Clientes;
import co.edu.univalle.modelo.Cuentas;
import co.edu.univalle.persistencia.IClienteDAO;
import co.edu.univalle.persistencia.IcuentaDAO;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 *
 * @author CQ 43 - 450LA
 */
@Stateless
public class CuentaLogica implements CuentaLogicaLocal {

   
@EJB
private IClienteDAO clienteDAO;    
@EJB
private IcuentaDAO cuentaDAO;

    @Override
    public void registrar(Cuentas cuenta) throws Exception {
        Clientes objCliente= clienteDAO.consultarPorCedula(cuenta.getCliCedula().getCliCedula());
        
              if(objCliente==null){
                  
                   throw new Exception ("no se puede registrar la cuenta, por que el cliente no existe");
              }
              
        Cuentas objCuenta = cuentaDAO.consultarPorNumero(cuenta.getCueNumero());
        
        if(objCuenta != null){
            throw new Exception ("la cuenta ya existe");
        }
    }

    @Override
    public void eliminar(Cuentas cuenta) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void modificar(Cuentas cuenta) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Cuentas> consultar() throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public Cuentas consultarPorNumero(String cuenta) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Cuentas> consultarCuentasCliente(Long documento) throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Cuentas> consultarCuentasActivas() throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
   

  
}
